<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>
<head>
{include file='header.tpl' JS=$smarty.const.BAOGG_JS CSS=$smarty.const.BAOGG_CSS}        
        
        <script type="text/javascript"> 
          var form_url='{$form_url}';
	var  LANG={$LANG};
	{literal}
Ext.onReady(function(){

	
                
                
                var form = new Ext.FormPanel({
                    url: form_url,
                    region: 'north',
                    el: "form",
                    frame: true,
		    bodyBorder :false,
                    bodyStyle: 'padding:15px 15px 0;',
                    height: 120,
                    items: [{
                        layout: 'column',
                        
                        items: [{
                            columnWidth: '0.3',
                            layout: 'form',
                            
                            items: [{
                                xtype: 'displayfield',
                                fieldLabel: LANG.translate_var_name,
                                id: 'translate_var_name',
                                name: 'translate_var_name',
                                readOnly:true,
                                anchor: '95%'
                            },{
                                xtype: 'displayfield',
                                fieldLabel: LANG.content,
                                name: 'content',
                                anchor: '95%'
                            }]
                        }, {
                            columnWidth: '0.3',
                            layout: 'form',
                            items: [{
                                id:'language_id2',
                                xtype: 'combo',
                                fieldLabel: LANG.language_id,
                                name: 'language_id2',
                                 store: LANG.store_language_id,
                                 autoSelect:true,
                                anchor: '95%',
                                forceSelection: true,
                  				triggerAction: 'all',
                                listeners: {
                                    "select":function(combo,record,index){
                                         
                                           if(record.get("field1") && Ext.getCmp("translate_var_id").getValue()){
                                        	   Ext.Ajax.request({
                                        		   
                                        		   url: '{/literal}{$smarty.const.BAOGG_BASE_URL}{literal}multilang/translatecontent/data/',
                                        		   
                                        		   success: function(o){res = eval("(" + o.responseText + ")");if(res.count>0){Ext.getCmp("content2").setValue(res.data[0]['content']);}else{Ext.getCmp("content2").setValue("");}},
                                        		   failure: function(){},                                        		  
                                        		   params: { language_id: record.get("field1"),translate_var_id:Ext.getCmp("translate_var_id").getValue() }
                                        		});
                                           }
                                     }
                                }
                            },{
                                xtype: 'textfield',
                                fieldLabel: LANG.content,
                                name: 'content2',
                                id: 'content2',
                                anchor: '95%'
                            },{
                                xtype: 'hidden',
                                name: 'translate_var_id',
                                id: 'translate_var_id',
                                anchor: '95%'
                            }]
                        }]
                    }],
                    
                    buttons: [{
                        text: LANG.save,
			handler :function(b,e){
				form.getForm().submit({
				    clientValidation: true,				  
				    params:{language_id:Ext.getCmp("language_id2").getValue()},
				    success: function(form, action) {					
				       top.Ext.example.msg(LANG.save_ok, action.result.msg);
				       grid.getStore().load()					
				    },
				    failure: function(form, action) {
					switch (action.failureType) {
					    case Ext.form.Action.CLIENT_INVALID:
						top.Ext.example.msg(LANG.failure, "Form fields may not be submitted with invalid values");
						break;
					    case Ext.form.Action.CONNECT_FAILURE:
						top.Ext.example.msg(LANG.failure, "Ajax communication failed");
						break;
					    case Ext.form.Action.SERVER_INVALID:
					       top.Ext.example.msg(LANG.failure, action.result.msg);
					       break;
					    default:
					      top.Ext.example.msg(LANG.failure, action.result.msg);
					      break;
				       }
				    }
				});
			}
                    }, {
                        text: LANG.search,
			handler:function(b,e){
				var params=form.getForm().getValues();
				params['translate_var_type_id']=Ext.getCmp("translate_var_type").getValue();
				grid.getStore().baseParams=Ext.apply(grid.getStore().baseParams,params);
				grid.getStore().load();
			}
                    }, {
                        text: LANG.reset,
			handler:function(b,e){form.getForm().reset();}
                    }]
                });
{/literal}
	{$grid}
{literal}
		


	 Ext.create('Ext.container.Viewport', {
    layout: 'border',
    renderTo: Ext.getBody(),
                    items: grid				
                });
		win_form.show().center().hide();

});
</script>
{/literal}
 
</head>
<body>
  
       
<div id="form"></div>
<div id="grid"></div>


</body>
</html>